package cn.com.dstz.admin.action;

import java.util.HashMap;
import java.util.Map;

import org.hibernate.Hibernate;
import org.hibernate.type.Type;

import cn.com.dstz.base.action.BaseAction;
import cn.com.dstz.common.web.springmvc.RealPathResolver;
import cn.com.dstz.utils.DataBaseUtils;

/**
 * 需要控制文件大小精度问题
 * @author 叶装装
 * 
 * 软件配置的实现方式：
 * 有一个资源管理器： 主要是管理 上传的资源的
 * 
 * 在第一步的配置界面， 得做一个
 *
 */
public class ResourceAct extends BaseAction{

	public void list( ){
		
		String sql = "select s.name as skinname, sf.name as name, sf.type as type, sf.size as size, sf.path as path, sf.datetime as datetime from dstz_skin s, dstz_skin_field sf where s.id = sf.skinid ";
		Map< String, Object > valueMap = new HashMap< String, Object >( );
		
		if( id != null && id != 0 ){
			sql += " and sf.skinid=:id";
			valueMap.put( "id", id );
		}
		
		this.responseToJsonObject( this.paginationBySQL( sql, null, valueMap,  "sf.datetime", DataBaseUtils.getAlias( new String[]{
				"skinname", "name", "type", "size", "path", "datetime", 
		}, new Type[]{
				Hibernate.STRING, Hibernate.STRING, Hibernate.STRING, Hibernate.DOUBLE, Hibernate.STRING, Hibernate.STRING, 
		} ) )  );
		
	}
	
	public void delete( ){
		
		if( id != null && id != 0 ){
			
			baseService.deleteBySql( "dstz_skin_field", DataBaseUtils.getData( new String[]{
					
			}, new Object[]{
					
			} ) );
			
		}
		
		
	}

	private Integer id;
	
	private static final long serialVersionUID = 1L;

	private RealPathResolver realPathResolver;		// 真实路径辅助类

	public void setRealPathResolver( RealPathResolver realPathResolver ) {
		this.realPathResolver = realPathResolver;
	}

	public Integer getId( ) {
		return id;
	}

	public void setId( Integer id ) {
		this.id = id;
	}
	
	
	
}
